import {HYEventStore} from 'hy-event-store'
import { getRanking } from '../service/api_music'



const rankingMap={0:"newRanking",1:"hotRanking",2:"originRanking",3:"upRanking"}
const rankingStore=new HYEventStore({
  state:{
      hotRanking:{}, //热门榜
      newRanking:{},//新歌榜
      originRanking:{}, //原创榜
      upRanking:{} //飙升
  },
  actions:{
    getRankDataAction(ctx){
      // 0 新歌榜 1 热门榜 2 原创榜 3飙升榜
      for(let i=0;i<4;i++){
        getRanking(i).then(res=>{
          switch(i){
             case 0:
               ctx.newRanking=res.playlist
               break;
             case 1:
               ctx.hotRanking=res.playlist
                break;
            case 2:
                ctx.originRanking=res.playlist
                  break;
             case 3:
              ctx.upRanking=res.playlist
                  break;
          }
       })
      }
    
    }
  }
})

export {
  rankingStore,
  rankingMap
}